package src.dynamic_programming;

/**
 * @author starsea
 * @date 2024-08-22 11:19
 */

public class Test04 {
    public static void main(String[] args) {
        String s="";
    }
    public static boolean isMatch(String s, String p) {
    s=" "+s;
    p=" "+p;
    boolean[][] dp=new boolean[s.length()][p.length()];
    dp[0][0]=true;
    for(int j=2;j<p.length()-1;j+=2)
    {
        if(p.charAt(j)=='*'){
            dp[0][j]=true;
        }
        else
        {
            break;
        }
    }
    for(int i=1;i<s.length();i++)
    {
        for(int j=1;j<p.length();j++)
        {
            if(s.charAt(i)==p.charAt(j) || p.charAt(j)=='.' )
            {
                dp[i][j]=dp[i-1][j-1];
            }
            else if(p.charAt(j)=='*')
            {
                if(p.charAt(j-1)=='.')
                {
                    dp[i][j]=dp[i][j-2] || dp[i-1][j];
                }else {

                    dp[i][j]=dp[i][j-1] || dp[i-1][j];
                }
            }
        }
    }
    return dp[s.length()-1][p.length()-1];
    }
}
